/**
 * @param {有效数据buffer} valid_buffer
 * @param {地址} address
 * @returns
 */
function filterData(valid_buffer, address) {
  let start = 0;
  let end = start + 1 + valid_buffer[start + 1];
  while (valid_buffer[start] != address) {
    start = end + 1;
    end = start + 1 + valid_buffer[start + 1];
    if (start >= valid_buffer.length) {
      break;
    }
  }
  return Uint8Array.prototype.slice
    .call(valid_buffer)
    .slice(start + 2, end + 1);
}
// console.log(buffer_copy);
// console.log(buffer_copy[0] === 1);
// console.log(buffer_copy.length);
// console.log(buffer_copy[1]);
// console.log(parseData(buffer_copy, 2, 4));
// console.log(parseData(buffer_copy, 1, 2));

module.exports.filterData = filterData;
